/**
 * Copyright Pravega Authors.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.pravega.storage.gcp;

import io.pravega.common.util.ConfigBuilder;
import io.pravega.common.util.Property;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Unit tests for {@link GCPStorageConfig}
 */
public class GCPStorageConfigTest {

    @Test
    public void testDefaultGCPConfig() {
        ConfigBuilder<GCPStorageConfig> builder = GCPStorageConfig.builder();
        builder.with(Property.named("bucket"), "testBucket")
                .with(Property.named("prefix"), "testPrefix");
        GCPStorageConfig config = builder.build();
        assertEquals("testBucket", config.getBucket());
        assertEquals("testPrefix/", config.getPrefix());
    }

    @Test
    public void testConstructGCPConfig() {
        ConfigBuilder<GCPStorageConfig> builder = GCPStorageConfig.builder();
        builder.with(Property.named("bucket"), "testBucket")
                .with(Property.named("prefix"), "testPrefix")
                .with(Property.named("account.type"), "testAccountType")
                .with(Property.named("project.id"), "testProjectId")
                .with(Property.named("client.email"), "testClientEmail")
                .with(Property.named("client.id"), "testClientId")
                .with(Property.named("private.key.id"), "testPrivateKeyId")
                .with(Property.named("private.key"), "testPrivateKey");

        GCPStorageConfig config = builder.build();
        assertEquals("testBucket", config.getBucket());
        assertEquals("testPrefix/", config.getPrefix());
        assertEquals("testAccountType", config.getAccountType());
        assertEquals("testProjectId", config.getProjectId());
        assertEquals("testClientEmail", config.getClientEmail());
        assertEquals("testClientId", config.getClientId());
        assertEquals("testPrivateKeyId", config.getPrivateKeyId());
        assertEquals("testPrivateKey", config.getPrivateKey());
    }
}
